package com.artqiyi.dollmachine.utils.manager;

import com.artqiyi.dollmachine.model.entity.UserInfoBean;

/**
 * author: PengCheng
 * time: 2017/12/8 0008
 * desc:
 */

public class UserInfoManager {
    private static UserInfoManager instance;

    private UserInfoBean mUserInfoBean;

    public static UserInfoManager getInstance() {
        if (instance == null) {
            synchronized (UserInfoManager.class) {
                if (instance == null) {
                    instance = new UserInfoManager();
                }
            }
        }
        return instance;
    }

    private UserInfoManager() {
        if (mUserInfoBean == null) {
            mUserInfoBean = new UserInfoBean();
        }
    }

    public void setUserInfoBean(UserInfoBean bean) {
        mUserInfoBean.setAvatar(bean.getAvatar());
        mUserInfoBean.setCoin(bean.getCoin());
        mUserInfoBean.setId(bean.getId());
        mUserInfoBean.setLive_openid(bean.getLive_openid());
        mUserInfoBean.setNickname(bean.getNickname());
        mUserInfoBean.setQcloud_sig(bean.getQcloud_sig());
        mUserInfoBean.setApi_token("Bearer " + bean.getApi_token());
        mUserInfoBean.setCoin_buy(bean.getCoin_buy());
        mUserInfoBean.setVideo_token(bean.getVideo_token());
    }

    public void setUserInfoBeanWithoutToken(UserInfoBean bean) {
        mUserInfoBean.setAvatar(bean.getAvatar());
        mUserInfoBean.setCoin(bean.getCoin());
        mUserInfoBean.setId(bean.getId());
        mUserInfoBean.setLive_openid(bean.getLive_openid());
        mUserInfoBean.setNickname(bean.getNickname());
        mUserInfoBean.setQcloud_sig(bean.getQcloud_sig());
        mUserInfoBean.setCoin_buy(bean.getCoin_buy());
        mUserInfoBean.setVideo_token(bean.getVideo_token());
    }

    public UserInfoBean getUserInfoBean() {
        return mUserInfoBean;
    }

    public void setToken(String token) {
        mUserInfoBean.setApi_token("Bearer " + token);
    }

}
